<template>
  <el-dialog :close-on-click-modal='false' v-drag :title="$t('被引用条目')" :v-if="dialogVisible" :visible.sync="dialogVisible" width="505px" @close='close' top="10vh">
    <div class="dialogContentBoxMaxHeight80">
      <el-table size='mini' ref="multipleTable" :data="tableList" tooltip-effect="dark" style="width: 100%">
        <el-table-column prop="name" :label="$t('引用模块名称')" align='center' min-width="100">
          <template slot-scope="scope">
            <tooltip :copyText="modeList[scope.row.name] || scope.row.name" class="wid190">
            </tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="value" :label="$t('引用名称')" align='center' min-width="100">
          <template slot-scope="scope">
            <tooltip :copyText="scope.row.value" class="wid190">
            </tooltip>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close">{{$t('取 消')}}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getMgmtMode } from '@/api/system/log'
export default {
  name: 'errorTools',
  data () {
    return {
      dialogVisible: false,
      tableList: [],
      modeList: {}
    }
  },
  methods: {
    init (data) {
      let info = data.info
      this.dialogVisible = true
      this.tableList = []
      this.$messages.error((data.name || data.id || '') + this.$t('对象被引用，无法删除'))
      for (let item in info) {
        this.tableList.push({ name: item, value: info[item] })
      }
      getMgmtMode().then(res => {
        this.modeList = {}
        for (let item of res.info) {
          this.modeList[item.name] = item.chinese_name
        }
      })
    },
    close () {
      this.dialogVisible = false
      this.tableList = []
    }
  }
}
</script>
